package org.bigdata.framework.core.controller;


import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.bigdata.framework.core.log.annotation.SysLog;
import org.bigdata.framework.core.log.enums.BusinessType;
import org.bigdata.framework.core.log.enums.OperatorType;
import org.bigdata.framework.core.model.Advertisement;
import org.bigdata.framework.core.model.Answer;
import org.bigdata.framework.core.model.Browse;
import org.bigdata.framework.core.model.Category;
import org.bigdata.framework.core.model.ClassesOnline;
import org.bigdata.framework.core.model.ClassesOnlineComment;
import org.bigdata.framework.core.model.Collect;
import org.bigdata.framework.core.model.Comment;
import org.bigdata.framework.core.model.Config;
import org.bigdata.framework.core.model.Course;
import org.bigdata.framework.core.model.CourseComment;
import org.bigdata.framework.core.model.CourseQuestion;
import org.bigdata.framework.core.model.Live;
import org.bigdata.framework.core.model.LiveQuestion;
import org.bigdata.framework.core.model.Log;
import org.bigdata.framework.core.model.Member;
import org.bigdata.framework.core.model.Message;
import org.bigdata.framework.core.model.Online;
import org.bigdata.framework.core.model.OnlineQuestion;
import org.bigdata.framework.core.model.Order;
import org.bigdata.framework.core.model.Paper;
import org.bigdata.framework.core.model.Question;
import org.bigdata.framework.core.model.QuestionDatabase;
import org.bigdata.framework.core.model.ShortFilm;
import org.bigdata.framework.core.model.ShortFilmComment;
import org.bigdata.framework.core.protocol.IBaseService;
import org.bigdata.framework.core.protocol.IPublicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore
@Controller
public class DeleteController extends BaseController{

	@Autowired
	private IBaseService baseService;
	@Autowired
	private IPublicService publicService;
	
	@SysLog(title="删除-广告",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("advertisementDel")
	@ResponseBody
	public void advertisementDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Advertisement advertisement = publicService.findAdvertisement(id);
			if(advertisement!=null){
				try {
					baseService.deleteAdvertisement(advertisement);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-浏览记录",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("browseDel")
	@ResponseBody
	public void browseDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Browse browse = publicService.findBrowse(id);
			if(browse!=null){
				try {
					baseService.deleteBrowse(browse);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-栏目",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("categoryDel")
	@ResponseBody
	public void categoryDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] iid = ids.split(";");
			boolean flag=true;
			for (String string : iid) {
				if(!"".equals(string)){
					Integer id = Integer.parseInt(string);
					Category category = publicService.findCategory(id);
					
					if(category!=null){
						HashMap<String, Object> queryParams = new HashMap<String, Object>();
						queryParams.put("=,categoryId",category.getId());
						Integer courseCount = publicService.getCourseCount(queryParams );
						if(courseCount!=null && courseCount>0){
							flag=false;
						}else{
							baseService.deleteCategory(category);
						}
					}
				}
			}
			if(!flag){
				if(iid.length>1){
					r.put("result", "success");
					r.put("msg", "部分【关联课程】的栏目没有删除");
				}else{
					r.put("result", "success");
					r.put("msg", "【关联课程】不能删除");
				}
			}else{
				r.put("result", "success");
				r.put("msg", "删除成功");
			}
			
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-网班",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("classesOnlineDel")
	@ResponseBody
	public void classesOnlineDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,classesOnlineId", iid);
			Integer liveCount = publicService.getLiveCount(queryParams);
			if(liveCount!=null && liveCount>0){
				r.put("result", "fail");
				r.put("msg", "关联直播不能删除");
			}else{
				ClassesOnline classesOnline = publicService.findClassesOnline(id);
				if(classesOnline!=null){
					try {
						baseService.deleteClassesOnline(classesOnline);
						r.put("result", "success");
						r.put("msg", "删除成功");
					} catch (Exception e) {
						r.put("result", "fail");
						r.put("msg", "删除失败");
					}
				}else{
					r.put("result", "fail");
					r.put("msg", "删除失败，请刷新列表重新操作");
				}
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-网班评论",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("classesOnlineCommentDel")
	@ResponseBody
	public void classesOnlineCommentDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					ClassesOnlineComment classesOnlineComment = publicService.findClassesOnlineComment(Integer.parseInt(string));
					if(classesOnlineComment!=null){
						baseService.deleteClassesOnlineComment(classesOnlineComment);
						classesOnlineComment=null;
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-收藏",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("collectDel")
	@ResponseBody
	public void collectDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Collect collect = publicService.findCollect(id);
			if(collect!=null){
				try {
					baseService.deleteCollect(collect);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-意见",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("commentDel")
	@ResponseBody
	public void commentDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					Comment comment = publicService.findComment(Integer.parseInt(string));
					if(comment!=null){
						baseService.deleteComment(comment);
						comment=null;
					}
					
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-配置",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("configDel")
	@ResponseBody
	public void configDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					Config config = publicService.findConfig(Integer.parseInt(string));
					if(config!=null){
						baseService.deleteConfig(config);
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-课程",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseDel")
	@ResponseBody
	public void courseDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Course course = publicService.findCourse(id);
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,courseId", iid);
			Integer onlineCount = publicService.getOnlineCount(queryParams);
			if(onlineCount!=null && onlineCount>0){
				r.put("result", "fail");
				r.put("msg", "关联微课不能删除");
			}else{
				if(course!=null){
					try {
						baseService.deleteCourse(course);
						r.put("result", "success");
						r.put("msg", "删除成功");
					} catch (Exception e) {
						r.put("result", "fail");
						r.put("msg", "删除失败");
					}
				}else{
					r.put("result", "fail");
					r.put("msg", "删除失败，请刷新列表重新操作");
				}
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-课程评论",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseCommentDel")
	@ResponseBody
	public void courseCommentDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] iid = ids.split(";");
			for (String string : iid) {
				if(!"".equals(string)){
					Integer id = Integer.parseInt(string);
					CourseComment courseComment = publicService.findCourseComment(id);
					if(courseComment!=null){
						baseService.deleteCourseComment(courseComment);
					}
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-课程组卷",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("courseQuestionDel")
	@ResponseBody
	public void courseQuestionDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			CourseQuestion courseQuestion = publicService.findCourseQuestion(id);
			if(courseQuestion!=null){
				try {
					baseService.deleteCourseQuestion(courseQuestion);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-直播",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("liveDel")
	@ResponseBody
	public void liveDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Live live = publicService.findLive(id);
			if(live!=null){
				try {
					baseService.deleteLive(live);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-直播组卷",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("liveQuestionDel")
	@ResponseBody
	public void liveQuestionDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			LiveQuestion liveQuestion = publicService.findLiveQuestion(id);
			if(liveQuestion!=null){
				try {
					baseService.deleteLiveQuestion(liveQuestion);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@RequestMapping("logDel")
	@ResponseBody
	public void logDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					Log log = publicService.findLog(Integer.parseInt(string));
					if(log!=null){
						baseService.deleteLog(log);
					}
					log=null;
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@RequestMapping("logDelAll")
	@ResponseBody
	public void logDelAll(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HashMap<String, String>r=new HashMap<String, String>();
		try {
			baseService.deleteLogAll();
			r.put("result", "success");
			r.put("msg", "删除成功");
		} catch (Exception e) {
			r.put("result", "fail");
			r.put("msg", "删除失败");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-前台用户",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("memberDel")
	@ResponseBody
	public void memberDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					Member member = publicService.findMember(Integer.parseInt(string));
					if(member!=null){
						baseService.deleteMember(member);
					}
					member=null;
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-消息",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("messageDel")
	@ResponseBody
	public void messageDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Message message = publicService.findMessage(id);
			if(message!=null){
				try {
					baseService.deleteMessage(message);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-微课",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("onlineDel")
	@ResponseBody
	public void onlineDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Online online = publicService.findOnline(id);
			if(online!=null){
				try {
					baseService.deleteOnline(online);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-微课组卷",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("onlineQuestionDel")
	@ResponseBody
	public void onlineQuestionDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			OnlineQuestion onlineQuestion = publicService.findOnlineQuestion(id);
			if(onlineQuestion!=null){
				try {
					baseService.deleteOnlineQuestion(onlineQuestion);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-订单",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("orderDel")
	@ResponseBody
	public void orderDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Order order = publicService.findOrder(id);
			if(order!=null){
				try {
					baseService.deleteOrder(order);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-题目",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("questionDel")
	@ResponseBody
	public void questionDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Question question = publicService.findQuestion(id);
			if(question!=null){
				try {
					baseService.deleteQuestion(question);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-题库",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("questionDatabaseDel")
	@ResponseBody
	public void questionDatabaseDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			
			HashMap<String, Object> queryParams = new HashMap<String, Object>();
			queryParams.put("=,questionDatabaseId", iid);
			Integer questionCount = publicService.getQuestionCount(queryParams);
			if(questionCount!=null && questionCount>0){
				r.put("result", "fail");
				r.put("msg", "关联题目不能删除");
			}else{
				QuestionDatabase questionDatabase = publicService.findQuestionDatabase(id);
				if(questionDatabase!=null){
					try {
						baseService.deleteQuestionDatabase(questionDatabase);
						r.put("result", "success");
						r.put("msg", "删除成功");
					} catch (Exception e) {
						r.put("result", "fail");
						r.put("msg", "删除失败");
					}
				}else{
					r.put("result", "fail");
					r.put("msg", "删除失败，请刷新列表重新操作");
				}
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-短视频",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("shortFilmDel")
	@ResponseBody
	public void shortFilmDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String ids = request.getParameter("ids");
		HashMap<String, String>r=new HashMap<String, String>();
		if(ids!=null && !"".equals(ids)){
			String[] splits = ids.split(";");
			for (String string : splits) {
				if(!"".equals(string)){
					ShortFilm shortFilm = publicService.findShortFilm(Integer.parseInt(string));
					if(shortFilm!=null){
						baseService.deleteShortFilm(shortFilm);
					}
					shortFilm=null;
				}
			}
			r.put("result", "success");
			r.put("msg", "删除成功");
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-短视频评论",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("shortFilmCommentDel")
	@ResponseBody
	public void shortFilmCommentList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			ShortFilmComment shortFilmComment = publicService.findShortFilmComment(id);
			if(shortFilmComment!=null){
				try {
					baseService.deleteShortFilmComment(shortFilmComment);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-卷子",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("paperDel")
	@ResponseBody
	public void paperDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Paper paper = publicService.findPaper(id);
			if(paper!=null){
				try {
					baseService.deletePaper(paper);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
	@SysLog(title="删除-答案",businessType=BusinessType.DELETE,operatorType=OperatorType.MANAGE)
	@RequestMapping("answerDel")
	@ResponseBody
	public void answerDel(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String iid = request.getParameter("id");
		HashMap<String, String>r=new HashMap<String, String>();
		if(iid!=null && !"".equals(iid)){
			Integer id = Integer.parseInt(iid);
			Answer answer = publicService.findAnswer(id);
			if(answer!=null){
				try {
					baseService.deleteAnswer(answer);
					r.put("result", "success");
					r.put("msg", "删除成功");
				} catch (Exception e) {
					r.put("result", "fail");
					r.put("msg", "删除失败");
				}
			}else{
				r.put("result", "fail");
				r.put("msg", "删除失败，请刷新列表重新操作");
			}
		}else{
			r.put("result", "fail");
			r.put("msg", "请选择数据");
		}
		String result = super.formatToJson(r);
		super.pringWriterToPage(result, "application/json", response);
	}
}
